
<script src="../js/libs/jquery.form.3.5.js"></script>
<script src="../js/libs/jquery.validate.js"></script>
<script type="text/javascript">
$(function(){
	//从服务器获取数据校验规则
	var validator = <{if $validator}>$.parseJSON('<{$validator}>')<{else}>''<{/if}>;
	$(".zxform").validate({
		rules: validator ? validator['rules'] : "",
		messages: validator ? validator['messages'] : "",
		submitHandler: function(form) {
			$(form).ajaxSubmit({
				dataType:  'json',
				beforeSubmit:
				function(formData, jqForm, options){
					showBlockMsg(".zxblockui", "");
					return true;
				},
				success:
				function(json, status) {
					var obj_win = json.top ? top : window;
					if(json.result == 1){
						/*
						showBlockMsg('.form', json.msg, 'ok');
                        window.setTimeout(function() {
                            if(json.url){
                                obj_win.location.href = json.url.replace(/&amp;/g,'&').replace(/&amp;/g,'&');
                            }else{
                                obj_win.location.reload();
                            }
                        }, 2000);
                        */
						if(json.msg)
                        	alert(json.msg);
                        if(json.url){
                            obj_win.location.href = json.url.replace(/&amp;/g,'&').replace(/&amp;/g,'&');
                        }else{
                            obj_win.location.reload();
                        }
					}else {
						if(json.msg)
							alert(json.msg);
                        if(json.url){
                            obj_win.location.href = json.url.replace(/&amp;/g,'&').replace(/&amp;/g,'&');
                        }else{
							hideBlockMsg('.zxblockui');
						}
                        /*
						showBlockMsg(".form", json.msg, 'error');
						if(json.url){
							obj_win.location.href = json.url.replace(/&amp;/g,'&').replace(/&amp;/g,'&');
						}else{
							window.setTimeout(function() {
								hideBlockMsg('.form');
							}, 2000);
						}
						*/
					}
				},
				error:
				function(xml, status){
					//hideBlockMsg('.form');
					alert(xml.responseText);
				}
			});
			return false;
		}
	});

    $(".form_botton").click(function(){
        if(!confirm($(this).attr("zxalert"))) return false;
        $(".zxform").submit();
    });
});
</script>
